package bdzeitor;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Conexao {
    String url = "jdbc:postgresql://localhost:5432/controlecaixa";
    String user = "postgres";
    String password = "facada";
    
    public Conexao(){
        FileReader reader;  
        try {
            BufferedReader input = new BufferedReader(new FileReader(new File("configBanco.txt"))); 
            this.url = input.readLine().split("=")[1];
            this.user = input.readLine().split("=")[1];
            this.password = input.readLine().split("=")[1];
        } catch (Exception ex) {
            System.out.println("Arquivo config não existe, carrega padrão");
        }
        
    }

    public Connection getConnection() throws SQLException {
        return DriverManager.getConnection(url, user, password);
    }
}
